package com.rainyun.rcmc.own.bukkit.main;

import com.google.gson.GsonBuilder;
import com.rainyun.rc.command.CmdPath;
import com.rainyun.rc.ioc.BeanNotInit;
import com.rainyun.rc.ioc.Beanzy;
import com.rainyun.rc.ioc.RainIOC;
import com.rainyun.rcmc.bukkit.BukGson;
import com.rainyun.rcmc.bukkit.BukkitPlugin;
import com.rainyun.rcmc.bukkit.RainBukkitUtil;
import com.rainyun.rcmc.bukkit.annotation.BukPlugin;
import com.rainyun.rcmc.own.bukkit.biz.BizRC;
import com.rainyun.rcmc.own.common.BeanRc;
import com.rainyun.rcmc.own.common.BeanRc.BeansRc;
import com.rainyun.rcmc.own.common.RcGlobal;
import org.bukkit.Bukkit;

import java.util.Map;
import java.util.logging.Logger;

/**主类*/
@BukPlugin(
		name = "RainCore",
		version = "1.0.0",
		author = {"Akr_on小林"},
		softdepend = {"PlaceholderAPI"},
		mail = "527125516@qq.com"
)
@BeanNotInit//必需
public class BukRainCore extends BukkitPlugin {

	static {
		//Nms兼容化所有插件
		RainBukkitUtil.NmsBukCompatify(null);
	}

	@Beanzy
	BizRC bizRc;
	@BeanRc(BeansRc.Logger)
	Logger logger;
	
	@Override
	public void onEnable() {
		super.onEnable();//载入类,生成IOC对象
		GsonBuilder gb = new GsonBuilder();
		BukGson.regAllToGsonBuilder(gb);
		RainIOC.set(BeansRc.Gson,gb.create());
		RainIOC.set(BeansRc.Logger,getLogger());
		RainIOC.set(BeansRc.Classloader,getClassLoader());

		Map<String, CmdPath<?>> cmds = RainBukkitUtil.initAllCmd(classes, this);//注册所有指令+监听器
		RainBukkitUtil.initAllListener(classes, this);//注册所有监听器
		RainIOC.set(BeansRc.Cmds,cmds);

		bizRc.reload(Bukkit.getConsoleSender());
	}
	@Override
	public void onDisable() {
		// 自己的代码
		super.onDisable();//卸载(必须)
	}

}
